package com.lsu.app.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lsu.app.bean.Log;
import com.lsu.app.service.LogService;
import com.lsu.app.mapper.LogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import java.time.LocalDateTime;

/**
 *
 * @description 针对表【log(日志表)】的数据库操作Service实现
 * @Date 2023-10-17 10:16:27
 * @author hjj
 */
@Service
public class LogServiceImpl extends ServiceImpl<LogMapper, Log> implements LogService{
    private final LogMapper mapper;

    @Autowired
    private HttpServletRequest request;

    public LogServiceImpl(LogMapper mapper) {
        this.mapper = mapper;
    }

    @Override
    public void createLog(String type, String value, String remake) {
        Object ob = request.getSession().getAttribute("username");
        if(ob==null){
            mapper.insert(new Log(remake,type,value,"成功"));
        }else {
            mapper.insert(new Log(ob.toString(),type,value,remake));
        }

    }
}




